import Taro, { Component } from '@tarojs/taro'
import { View, Image, Text } from '@tarojs/components'
import { AtButton, } from 'taro-ui'
import { DNavBar, DAtInpute } from '@/components'
import sdk from '@/common/sdk'
import http from '@/api'
import { handleIdCard } from '@/utils'
import './index.scss'

export default class AccountBookApprove extends Component {
  state = {
    // successIcon: require('@/assets/images/success@2x.png')
    timeIcon: require('@/assets/images/time@2x.png'),
    accountInfo: ''
  }

  componentDidMount() {
    this.infoByEnterprise()
  }

  async infoByEnterprise() {
    let accountInfo = await http.infoByEnterprise()
    this.setState({
      accountInfo
    })
  }
  toHome() {
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端

    if (isAndroid) {
      if (window.bridge) {
        // 跳转首页
        return sdk.setSkipCustom(0)
      }
    }

    if (isiOS) {
      window.webkit.messageHandler.backToHomepage()
      return
    }
  }

  render() {
    const { accountInfo } = this.state

    return (
      <View className="accountbook_approve">
        <DNavBar title="开通电子账簿"></DNavBar>

        <View className="container">
          <View className="top">
            {/* <Image src={this.state.successIcon} className="successIcon"></Image> */}
            <Image src={this.state.timeIcon} className="successIcon"></Image>
            <Text className="top_text">待审核</Text>
          </View>

          <View className="body">
            <View className="body_item">
              <Text>账户户名</Text>
              <Text>{accountInfo.accountNm || '--'}</Text>
            </View>
            <View className="body_item">
              <Text>账号</Text>
              <Text>{handleIdCard(accountInfo && accountInfo.account)}</Text>
            </View>
            <View className="body_item">
              <Text>银行代码</Text>
              <Text>{accountInfo.bankCode || '--'}</Text>
            </View>
            <View className="body_item">
              <Text>开户行行号</Text>
              <Text>{accountInfo.bankNum || '--'}</Text>
            </View>
            <View className="body_item">
              <Text>开户行名称</Text>
              <Text>{accountInfo.bankNm || '--'}</Text>
            </View>
          </View>

          <AtButton onClick={this.toHome.bind(this)}>回到首页</AtButton>
        </View>
      </View>
    )
  }
}
